package com.xinqi.modules.chat.chat.official.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.chat.chat.official.client.ChatAssistantContentClient;
import com.xinqi.modules.chat.chat.official.dto.req.ChatAssistantContentCreateDTO;
import com.xinqi.modules.chat.chat.official.dto.req.ChatAssistantContentMainDTO;
import com.xinqi.modules.chat.chat.official.dto.req.ChatAssistantContentTotalDTO;
import com.xinqi.modules.chat.chat.official.dto.req.ChatAssistantContentUpdateDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 新奇提醒消息记录表降级处理
 *
 * @author: yyzhen
 * @date: 2023/05/06
 */
@Slf4j
@Component
public class ChatAssistantContentFallbackFactory implements FallbackFactory<ChatAssistantContentClient> {

    @Override
    public ChatAssistantContentClient create(Throwable throwable) {
        log.error("新奇助手服务调用失败:{}", throwable.getMessage());
        return new ChatAssistantContentClient() {
            @Override
            public R<Boolean> batchInsert(List<ChatAssistantContentCreateDTO> dto) {

                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<Boolean> batchUpdateMain(ChatAssistantContentMainDTO dto) {

                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<Boolean> batchUpdateTotal(List<ChatAssistantContentTotalDTO> dto) {

                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<Boolean> batchUpdate(List<ChatAssistantContentUpdateDTO> dto) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

        };
    }
}
